home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / PInterfaces / Events.p < prev    next >
Text File  |  1996-05-01  |  8KB  |  319 lines

  1. {
  2.      File:        Events.p
  3.  
  4.      Contains:    Event Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 8
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT Events;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __EVENTS__}
  28. {$SETC __EVENTS__ := 1}
  29.  
  30. {$I+}
  31. {$SETC EventsIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __OSUTILS__}
  35. {$I OSUtils.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __QUICKDRAW__}
  38. {$I Quickdraw.p}
  39. {$ENDC}
  40. {$IFC UNDEFINED __TYPES__}
  41. {$I Types.p}
  42. {$ENDC}
  43.  
  44. {$PUSH}
  45. {$ALIGN MAC68K}
  46. {$LibExport+}
  47.  
  48.  
  49. TYPE
  50.     EventKind                            = UInt16;
  51.     EventMask                            = UInt16;
  52.  
  53. CONST
  54.     nullEvent                    = 0;
  55.     mouseDown                    = 1;
  56.     mouseUp                        = 2;
  57.     keyDown                        = 3;
  58.     keyUp                        = 4;
  59.     autoKey                        = 5;
  60.     updateEvt                    = 6;
  61.     diskEvt                        = 7;
  62.     activateEvt                    = 8;
  63.     osEvt                        = 15;
  64.     kHighLevelEvent                = 23;
  65.     mDownMask                    = $02;                            {  mouse button pressed }
  66.     mUpMask                        = $04;                            {  mouse button released }
  67.     keyDownMask                    = $08;                            {  key pressed }
  68.     keyUpMask                    = $10;                            {  key released }
  69.     autoKeyMask                    = $20;                            {  key repeatedly held down }
  70.     updateMask                    = $40;                            {  window needs updating }
  71.     diskMask                    = $80;                            {  disk inserted }
  72.     activMask                    = $0100;                        {  activate/deactivate window }
  73.     highLevelEventMask            = $0400;                        {  high-level events (includes AppleEvents) }
  74.     osMask                        = $8000;                        {  operating system events (suspend, resume) }
  75.     everyEvent                    = $FFFF;                        {  all of the above }
  76.  
  77.     charCodeMask                = $000000FF;
  78.     keyCodeMask                    = $0000FF00;
  79.     adbAddrMask                    = $00FF0000;
  80.     osEvtMessageMask            = $FF000000;                    {  OS event messages.  Event (sub)code is in the high byte of the message field. }
  81.     mouseMovedMessage            = $00FA;
  82.     suspendResumeMessage        = $0001;
  83.     resumeFlag                    = 1;                            {  Bit 0 of message indicates resume vs suspend }
  84.     convertClipboardFlag        = 2;                            {  Bit 1 in resume message indicates clipboard change }
  85.  
  86.  
  87. TYPE
  88.     EventModifiers                        = UInt16;
  89.  
  90. CONST
  91.                                                                 {  modifiers  }
  92.     activeFlagBit                = 0;                            {  activate? (activateEvt and mouseDown) }
  93.     btnStateBit                    = 7;                            {  state of button? }
  94.     cmdKeyBit                    = 8;                            {  command key down? }
  95.     shiftKeyBit                    = 9;                            {  shift key down? }
  96.     alphaLockBit                = 10;                            {  alpha lock down? }
  97.     optionKeyBit                = 11;                            {  option key down? }
  98.     controlKeyBit                = 12;                            {  control key down? }
  99.     rightShiftKeyBit            = 13;                            {  right shift key down? }
  100.     rightOptionKeyBit            = 14;                            {  right Option key down? }
  101.     rightControlKeyBit            = 15;                            {  right Control key down? }
  102.     activeFlag                    = $01;
  103.     btnState                    = $80;
  104.     cmdKey                        = $0100;
  105.     shiftKey                    = $0200;
  106.     alphaLock                    = $0400;
  107.     optionKey                    = $0800;
  108.     controlKey                    = $1000;
  109.     rightShiftKey                = $2000;
  110.     rightOptionKey                = $4000;
  111.     rightControlKey                = $8000;
  112.  
  113.     kNullCharCode                = 0;
  114.     kHomeCharCode                = 1;
  115.     kEnterCharCode                = 3;
  116.     kEndCharCode                = 4;
  117.     kHelpCharCode                = 5;
  118.     kBellCharCode                = 7;
  119.     kBackspaceCharCode            = 8;
  120.     kTabCharCode                = 9;
  121.     kLineFeedCharCode            = 10;
  122.     kVerticalTabCharCode        = 11;
  123.     kPageUpCharCode                = 11;
  124.     kFormFeedCharCode            = 12;
  125.     kPageDownCharCode            = 12;
  126.     kReturnCharCode                = 13;
  127.     kFunctionKeyCharCode        = 16;
  128.     kEscapeCharCode                = 27;
  129.     kClearCharCode                = 27;
  130.     kLeftArrowCharCode            = 28;
  131.     kRightArrowCharCode            = 29;
  132.     kUpArrowCharCode            = 30;
  133.     kDownArrowCharCode            = 31;
  134.     kDeleteCharCode                = 127;
  135.     kNonBreakingSpaceCharCode    = 202;
  136.  
  137.  
  138. TYPE
  139.     EventRecordPtr = ^EventRecord;
  140.     EventRecord = RECORD
  141.         what:                    EventKind;
  142.         message:                UInt32;
  143.         when:                    UInt32;
  144.         where:                    Point;
  145.         modifiers:                EventModifiers;
  146.     END;
  147.  
  148.     KeyMap                                = ARRAY [0..127] OF BOOLEAN;
  149. {$IFC FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE }
  150.     FKEYProcPtr = ProcPtr;  { PROCEDURE FKEY; }
  151.  
  152.     FKEYUPP = UniversalProcPtr;
  153.  
  154. CONST
  155.     uppFKEYProcInfo = $00000000;
  156.  
  157. FUNCTION NewFKEYProc(userRoutine: FKEYProcPtr): FKEYUPP;
  158.     {$IFC NOT GENERATINGCFM }
  159.     INLINE $2E9F;
  160.     {$ENDC}
  161.  
  162. PROCEDURE CallFKEYProc(userRoutine: FKEYUPP);
  163.     {$IFC NOT GENERATINGCFM}
  164.     INLINE $205F, $4E90;
  165.     {$ENDC}
  166. PROCEDURE GetMouse(VAR mouseLoc: Point);
  167.     {$IFC NOT GENERATINGCFM}
  168.     INLINE $A972;
  169.     {$ENDC}
  170. FUNCTION Button: BOOLEAN;
  171.     {$IFC NOT GENERATINGCFM}
  172.     INLINE $A974;
  173.     {$ENDC}
  174. FUNCTION StillDown: BOOLEAN;
  175.     {$IFC NOT GENERATINGCFM}
  176.     INLINE $A973;
  177.     {$ENDC}
  178. FUNCTION WaitMouseUp: BOOLEAN;
  179.     {$IFC NOT GENERATINGCFM}
  180.     INLINE $A977;
  181.     {$ENDC}
  182. FUNCTION TickCount: UInt32;
  183.     {$IFC NOT GENERATINGCFM}
  184.     INLINE $A975;
  185.     {$ENDC}
  186. PROCEDURE GetKeys(VAR theKeys: KeyMap);
  187.     {$IFC NOT GENERATINGCFM}
  188.     INLINE $A976;
  189.     {$ENDC}
  190. FUNCTION KeyTranslate(transData: UNIV Ptr; keycode: UInt16; VAR state: UInt32): UInt32;
  191.     {$IFC NOT GENERATINGCFM}
  192.     INLINE $A9C3;
  193.     {$ENDC}
  194. FUNCTION GetCaretTime: UInt32;
  195.     {$IFC NOT GENERATINGCFM}
  196.     INLINE $2EB8, $02F4;
  197.     {$ENDC}
  198. {$ENDC}
  199. {$IFC FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED }
  200. {  Obsolete event types & masks  }
  201.  
  202. CONST
  203.     networkEvt                    = 10;
  204.     driverEvt                    = 11;
  205.     app1Evt                        = 12;
  206.     app2Evt                        = 13;
  207.     app3Evt                        = 14;
  208.     app4Evt                        = 15;
  209.     networkMask                    = $0400;
  210.     driverMask                    = $0800;
  211.     app1Mask                    = $1000;
  212.     app2Mask                    = $2000;
  213.     app3Mask                    = $4000;
  214.     app4Mask                    = $8000;
  215.  
  216.  
  217. TYPE
  218.     EvQElPtr = ^EvQEl;
  219.     EvQEl = RECORD
  220.         qLink:                    QElemPtr;
  221.         qType:                    SInt16;
  222.         evtQWhat:                EventKind;                                {  this part is identical to the EventRecord as defined above  }
  223.         evtQMessage:            UInt32;
  224.         evtQWhen:                UInt32;
  225.         evtQWhere:                Point;
  226.         evtQModifiers:            EventModifiers;
  227.     END;
  228.  
  229.     GetNextEventFilterProcPtr = Register68kProcPtr;  { PROCEDURE GetNextEventFilter(VAR theEvent: EventRecord; VAR result: BOOLEAN); }
  230.  
  231.     GetNextEventFilterUPP = UniversalProcPtr;
  232.  
  233. CONST
  234.     uppGetNextEventFilterProcInfo = $000000BF;
  235.  
  236. FUNCTION NewGetNextEventFilterProc(userRoutine: GetNextEventFilterProcPtr): GetNextEventFilterUPP;
  237.     {$IFC NOT GENERATINGCFM }
  238.     INLINE $2E9F;
  239.     {$ENDC}
  240.  
  241. PROCEDURE CallGetNextEventFilterProc(VAR theEvent: EventRecord; VAR result: BOOLEAN; userRoutine: GetNextEventFilterUPP);
  242.     {$IFC NOT GENERATINGCFM}
  243.     {To be implemented:  Glue to move parameters into registers.}
  244.     {$ENDC}
  245.  
  246. TYPE
  247.     GNEFilterUPP                        = GetNextEventFilterUPP;
  248. FUNCTION GetEvQHdr: QHdrPtr;
  249.     {$IFC NOT GENERATINGCFM}
  250.     INLINE $2EBC, $0000, $014A;
  251.     {$ENDC}
  252. FUNCTION GetDblTime: UInt32;
  253.     {$IFC NOT GENERATINGCFM}
  254.     INLINE $2EB8, $02F0;
  255.     {$ENDC}
  256. PROCEDURE SetEventMask(value: EventMask);
  257.     {$IFC NOT GENERATINGCFM}
  258.     INLINE $31DF, $0144;
  259.     {$ENDC}
  260. FUNCTION PPostEvent(eventCode: EventKind; eventMsg: UInt32; VAR qEl: EvQElPtr): OSErr;
  261.     {$IFC NOT GENERATINGCFM}
  262.     INLINE $225F, $201F, $305F, $A12F, $2288, $3E80;
  263.     {$ENDC}
  264. FUNCTION KeyTrans(transData: UNIV Ptr; keycode: UInt16; VAR state: UInt32): UInt32;
  265.     {$IFC NOT GENERATINGCFM}
  266.     INLINE $A9C3;
  267.     {$ENDC}
  268. FUNCTION GetNextEvent(eventMask: EventMask; VAR theEvent: EventRecord): BOOLEAN;
  269.     {$IFC NOT GENERATINGCFM}
  270.     INLINE $A970;
  271.     {$ENDC}
  272. FUNCTION WaitNextEvent(eventMask: EventMask; VAR theEvent: EventRecord; sleep: UInt32; mouseRgn: RgnHandle): BOOLEAN;
  273.     {$IFC NOT GENERATINGCFM}
  274.     INLINE $A860;
  275.     {$ENDC}
  276. FUNCTION EventAvail(eventMask: EventMask; VAR theEvent: EventRecord): BOOLEAN;
  277.     {$IFC NOT GENERATINGCFM}
  278.     INLINE $A971;
  279.     {$ENDC}
  280. FUNCTION PostEvent(eventNum: EventKind; eventMsg: UInt32): OSErr;
  281.     {$IFC NOT GENERATINGCFM}
  282.     INLINE $201F, $305F, $A02F, $3E80;
  283.     {$ENDC}
  284. FUNCTION OSEventAvail(mask: EventMask; VAR theEvent: EventRecord): BOOLEAN;
  285.     {$IFC NOT GENERATINGCFM}
  286.     INLINE $205F, $301F, $A030, $5240, $1E80;
  287.     {$ENDC}
  288. FUNCTION GetOSEvent(mask: EventMask; VAR theEvent: EventRecord): BOOLEAN;
  289.     {$IFC NOT GENERATINGCFM}
  290.     INLINE $205F, $301F, $A031, $5240, $1E80;
  291.     {$ENDC}
  292. PROCEDURE FlushEvents(whichMask: EventMask; stopMask: EventMask);
  293.     {$IFC NOT GENERATINGCFM}
  294.     INLINE $201F, $A032;
  295.     {$ENDC}
  296. PROCEDURE SystemClick({CONST}VAR theEvent: EventRecord; theWindow: WindowRef);
  297.     {$IFC NOT GENERATINGCFM}
  298.     INLINE $A9B3;
  299.     {$ENDC}
  300. PROCEDURE SystemTask;
  301.     {$IFC NOT GENERATINGCFM}
  302.     INLINE $A9B4;
  303.     {$ENDC}
  304. FUNCTION SystemEvent({CONST}VAR theEvent: EventRecord): BOOLEAN;
  305.     {$IFC NOT GENERATINGCFM}
  306.     INLINE $A9B2;
  307.     {$ENDC}
  308. {$ENDC}
  309. {$ALIGN RESET}
  310. {$POP}
  311.  
  312. {$SETC UsingIncludes := EventsIncludes}
  313.  
  314. {$ENDC} {__EVENTS__}
  315.  
  316. {$IFC NOT UsingIncludes}
  317.  END.
  318. {$ENDC}
  319.